﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using DAL;

namespace BLL
{
   public partial class usersystemnodeManager
    {
       //根据条件获取日志
       public IQueryable<usersystemnode> GetByTime(string login, string leave, string opertor)
       {
           ZG_OAEntities ds = new ZG_OAEntities();
           var query = from obj in ds.usersystemnode orderby obj.id descending select obj;
           if (!string.IsNullOrEmpty(login) && login!="null")
           {
               DateTime dt = Convert.ToDateTime(login);
               query = from obj in query where obj.loginTime >= dt orderby obj.id descending select obj;
           }
           if (!string.IsNullOrEmpty(leave) && leave != "null")
           {
               DateTime dt2 = Convert.ToDateTime(leave);
               query = from obj in query where obj.leaveTime <= dt2 orderby obj.id descending select obj;
           }
           if (!string.IsNullOrEmpty(opertor) && opertor != "null")
           {
               if (opertor != "所有操作员")
               {
                   query = from obj in query where obj.username == opertor orderby obj.id descending select obj;
               }
           }
           return query;
       }
       public bool delLog()
       {
           IQueryable<usersystemnode> delAll = db.GetAll();
           if (delAll != null)
           {
               foreach (var item in delAll)
               {
                   db.Delete(item);
               }
               db.SaveChanges();
               return true;
           }
           else
           {
               return false;
           }
       }
    }
}
